package com.mdhw.utils;

public class PhoneNumberUtil {

    public static String maskPhoneNumber(String phone){
        if(phone == null || phone.length() != 11){
            return phone;
        }
        return phone.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2");
    }

    public static String maskPhoneNumber2(String phone){
        if(phone == null || phone.length() != 11){
            return phone;
        }
        return phone.replaceAll("(\\d{3})\\d{5}(\\d{3})","$1****$2");
    }
    public static void main(String[] args) {
        String oldPhone = "15880277500";
        String newPhone = maskPhoneNumber(oldPhone);
        System.out.println(newPhone);
    }
}
